package com.itheima.comtroller;


import com.itheima.pojo.User;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import javax.servlet.http.HttpServletRequest;

@RestController
public class RequestController {
    /*@RequestMapping("/simpleParam")

    public String simpleParam(HttpServletRequest request){
        String name =request.getParameter("name");
        String ageStr = request.getParameter("age");

        int age=Integer.parseInt(ageStr);
        System.out.println(name+":"+age);
        return "OK";
    }*/

    @RequestMapping("/simpleParam")

    public String simpleParam(String name,Integer age){

        System.out.println(name+":"+age);
        return "OK";
    }
    @RequestMapping("/simplePojo")
    public String simplePojo(User user){
        System.out.println(user);
        return "OK";
    }
    @RequestMapping("/complexPojo")
    public String complexPojo(User user){
        System.out.println(user);
        return "OK";
    }

    @RequestMapping("/jsonParam")
    public String jsonParam(@RequestBody User user){
        System.out.println(user);
        return "ok";
    }
    @RequestMapping("/path/{id}/{name}")
    public String pathParam(@PathVariable Integer id,@PathVariable String name){
        System.out.println(id+name);
        return "oky";
    }

}
